package com.scau.os.course_manager;

import com.scau.os.course_manager.bean.PCB;
import com.scau.os.course_manager.bean.ProcessState;

import java.util.ArrayList;
import java.util.List;

public class ProcessPool {
    private static final ProcessPool instance=new ProcessPool();
    public static ProcessPool getInstance(){
        return instance;
    }
    public PCB idle=new PCB();
    public static final int MAX_PROCESS=10;
    /**
     *已经进入内存当中，随时可以准备执行的进程，进程的挑选也是
     *从这里开始的
     */
    public List<PCB> ready=new ArrayList<>();

    /**
     * 因为某种原因阻塞的进程
     */
    public List<PCB> block=new ArrayList<>();

    public List<PCB> blank=new ArrayList<>(10);

    public List<PCB>all=new ArrayList<>();

    private ProcessPool() {
        idle.isIdle=true;
        idle.setState(ProcessState.CREATE);
        for(int i=1;i<=MAX_PROCESS;i++) {
            PCB pcb=new PCB();
            blank.add(pcb);
            all.add(pcb);
            pcb.setState(ProcessState.CREATE);
        }
        all.add(idle);
    }


}
